﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Meqs.Entity;
using Meqs.Logic.Interface;

public partial class Base_School_StaffIndexList : ContainerBasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    //初始化教师姓名树列表
    [System.Web.Services.WebMethod]
    public static List<TeacherInfo> InitTeacherList()
    {
        List<TeacherInfo> teacherlist = new List<TeacherInfo>();
        ITeacherInfoLogic teacherInfoLogic = Container<ITeacherInfoLogic>.Instance;
        teacherlist = (List<TeacherInfo>)teacherInfoLogic.GetAllTeacherOrderByPinyin(Common.GetConstSchoolMark());
        return teacherlist;
    }

    [System.Web.Services.WebMethod]
    public static int InsertTeacherToCause(int TeachID, int iCauseID)
    {
        Hashtable ht = new Hashtable();
        ht.Add("TeachID", TeachID);
        ht.Add("CauseID", iCauseID);
        int iCount = Container<ITeachClsCauseLogic>.Instance.FindCount(ht);

        //如果已经存在，则返回-1
        if (iCount > 0)
            return -1;

        //添加教师到关系表中
        TeachClsCause tcc = new TeachClsCause(TeachID, iCauseID, 0);
        Container<ITeachClsCauseLogic>.Instance.InsertTeachClsCause(tcc);
        return 1;
    }

    [System.Web.Services.WebMethod]
    public static int InsertTeacherToGrade(int teachID, int gradeID)
    {
        Hashtable ht = new Hashtable();
        ht.Add("TeacherID", teachID);
        ht.Add("Grade", gradeID);
        ht.Add("SchoolMark", SchoolMark);
        ht.Add("SchoolYear", SchoolCommon.Sch_SchoolInfo.SchoolYear);
        ht.Add("Term", SchoolCommon.Sch_SchoolInfo.SchoolTerm);
        int iCount = Container<IGradeGroupLogic>.Instance.FindCount(ht);

        //如果已经存在，则返回-1
        if (iCount > 0)
            return -1;

        //添加教师到关系表中
        GradeGroup gg = new GradeGroup();
        gg.Grade = gradeID;
        gg.SchoolMark = SchoolMark;
        gg.SchoolYear = SchoolCommon.Sch_SchoolInfo.SchoolYear;
        gg.Term = SchoolCommon.Sch_SchoolInfo.SchoolTerm;
        gg.TeacherID = teachID;

        return Container<IGradeGroupLogic>.Instance.Create(gg);
    }

    [System.Web.Services.WebMethod]
    public static int InsertTeacherToStuff(int teachID, int roleID)
    {
        Hashtable ht = new Hashtable();
        ht.Add("TeacherID", teachID);
        ht.Add("RoleID", roleID);
        ht.Add("SchoolMark", SchoolMark);
        ht.Add("SchoolYear", SchoolCommon.Sch_SchoolInfo.SchoolYear);
        ht.Add("Term", SchoolCommon.Sch_SchoolInfo.SchoolTerm);
        int iCount = Container<ITeacherRolesLogic>.Instance.FindCount(ht);

        //如果已经存在，则返回-1
        if (iCount > 0)
            return -1;

        //添加教师到关系表中
        TeacherRoles tr = new TeacherRoles();
        tr.RoleID = roleID;
        tr.GreadID = 0;
        tr.CauseID = 0;
        tr.SchoolMark = SchoolMark;
        tr.SchoolYear = SchoolCommon.Sch_SchoolInfo.SchoolYear;
        tr.Term = SchoolCommon.Sch_SchoolInfo.SchoolTerm;
        tr.TeacherID = teachID;

        return Container<ITeacherRolesLogic>.Instance.Create(tr);
    }
}
